<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="header">
    <div class="container">
        <div class="header-content">
            <div class="logo">
                <a href="index.jsp">淘乐乐商城</a>
            </div>
            <div class="nav">
                <a href="index.jsp">首页</a>
                <a href="products.jsp">全部商品</a>
                <a href="cart.jsp">购物车</a>
                <a href="my-orders.jsp">我的订单</a>
            </div>
            <div class="user-info">
                <% if (session.getAttribute("userId") != null) { %>
                    <div class="user-dropdown">
                        <span class="user-name">
                            <i class="fas fa-user"></i>
                            ${sessionScope.username}
                            <i class="fas fa-angle-down"></i>
                        </span>
                        <div class="dropdown-content">
                            <a href="profile.jsp">
                                <i class="fas fa-user-circle"></i>
                                我的淘乐乐
                            </a>
                            <a href="my-orders.jsp">
                                <i class="fas fa-shopping-bag"></i>
                                我的订单
                            </a>
                            <div class="dropdown-divider"></div>
                            <a href="logout">
                                <i class="fas fa-sign-out-alt"></i>
                                退出登录
                            </a>
                        </div>
                    </div>
                    <a href="logout">退出</a>
                <% } else { %>
                    <a href="login.jsp">登录</a>
                    <a href="register.jsp">注册</a>
                <% } %>
            </div>
        </div>
    </div>
</div>

<style>
    /* 用户下拉菜单样式 */
    .user-dropdown {
        position: relative;
        display: inline-block;
    }
    
    .user-name {
        display: flex;
        align-items: center;
        gap: 5px;
        cursor: pointer;
        padding: 5px 10px;
        border-radius: 4px;
        color: white;
    }
    
    .user-name:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    .dropdown-content {
        display: none;
        position: absolute;
        right: 0;
        top: 100%;
        background-color: white;
        min-width: 160px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-radius: 4px;
        z-index: 1000;
    }
    
    .user-dropdown:hover .dropdown-content {
        display: block;
    }
    
    .dropdown-content a {
        color: #666;
        padding: 10px 15px;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .dropdown-content a:hover {
        background-color: #f5f5f5;
        color: #ff4d4f;
    }
    
    .dropdown-divider {
        height: 1px;
        background-color: #eee;
        margin: 5px 0;
    }
    
    .header {
        background-color: #ff4d4f;
        padding: 15px 0;
        color: white;
    }
    
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 15px;
    }
    
    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .logo a {
        color: white;
        text-decoration: none;
        font-size: 24px;
        font-weight: bold;
    }
    
    .nav {
        display: flex;
        gap: 20px;
    }
    
    .nav a {
        color: white;
        text-decoration: none;
        padding: 5px 10px;
        border-radius: 4px;
        transition: background-color 0.3s;
    }
    
    .nav a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    .user-info {
        display: flex;
        gap: 15px;
        align-items: center;
    }
    
    .user-info a {
        color: white;
        text-decoration: none;
    }
    
    .user-info a:hover {
        text-decoration: underline;
    }
</style> 